package com.monster.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.monster.entity.LoginResult;
import com.monster.mapper.UserLoginMapper;
import com.monster.pojo.User;
import com.monster.service.UserLoginService;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.UUID;
@Service
@Transactional
public class UserLoginServiceImpl extends ServiceImpl<UserLoginMapper, User> implements UserLoginService {
    //用户登录
    @Override
    public LoginResult UserLogin(User user) {
        QueryWrapper<User> checkItemQueryWrapper = new QueryWrapper<>();
        QueryWrapper<User> wrapper = new QueryWrapper<User>();
        wrapper.eq("USERNAME", user.getUsername());
        wrapper.eq("PASSWORD",user.getPassword());
        List<User> list = this.list(wrapper);
        if(list.size() != 0){
            String uuid = UUID.randomUUID().toString();
            return new LoginResult(true, uuid);
        }else{
            return new LoginResult(false,"账号或者密码错误");
        }
    }
}
